package com.example.demo.service;

import com.example.demo.entity.Commentsinfo;
import com.example.demo.entity.ReplayCommentsinfo;
import com.example.demo.mapper.CommentsMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CommentsService {


    @Resource
    private CommentsMapper commentsMapper;

    //添加评论
    public int addComments(Commentsinfo commentsinfo){
        return commentsMapper.addComments(commentsinfo);
    }

    //根据aid查找评论
    public List<Commentsinfo> getcommentsbyaid (Integer aid){
        return commentsMapper.getcommentsbyaid(aid);
    }


    //赞评论
    public int addGCount(Integer id){
        return commentsMapper.addGCount(id);
    }

    //踩评论
    public int addBCount(Integer id){
        return commentsMapper.addBCount(id);
    }

    //根据评论的id，获取评论的回复列表
    public List<ReplayCommentsinfo> getReplayCommentsByCid(Integer cid){
        return commentsMapper.getReplayCommentsByCid(cid);
    }


    //删除comments表里面的评论
    public int delCommentsById(Integer id) {
        return commentsMapper.delCommentsById(id);
    }

    //根据评论id在comments表里面找uid
    public int getUidById(Integer id) {
        return commentsMapper.getUidById(id);
    }

    //添加评论的回复
    public int addReplayComments(ReplayCommentsinfo replayCommentsinfo) {
        return commentsMapper.addReplayComments(replayCommentsinfo);
    }


    //赞二级评论
    public int addGCount2(Integer id){
        return commentsMapper.addGCount2(id);
    }

    //踩二级评论
    public int addBCount2(Integer id){
        return commentsMapper.addBCount2(id);
    }

    //删除replaycomments表里面的评论
    public int delCommentsById2(Integer id) {
        return commentsMapper.delCommentsById2(id);
    }

    //根据评论回复id在replaycomments表里面找uid
    public int getUidById2(Integer id) {
        return commentsMapper.getUidById2(id);
    }

    public int getCidByRid(int rid) {
        return commentsMapper.getCidByRid(rid);
    }

    //添加评论的回复
    public int addReplayComments2(ReplayCommentsinfo replayCommentsinfo) {
        return commentsMapper.addReplayComments2(replayCommentsinfo);
    }

    //更新comments表的头像
    public int updateCommentsPhoto(Integer uid, String photoPathRe) {
        return commentsMapper.updateCommentsPhoto(uid,photoPathRe);
    }

    public int updateCReplayommentsPhoto(Integer uid, String photoPathRe) {
        return commentsMapper.updateReplayCommentsPhoto(uid,photoPathRe);
    }
}
